package com.cn.bulu.controller;

import java.io.PrintWriter;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.log4j.Logger;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import com.cn.bulu.service.PayService;

/**
 * @author XiaGuanghui  2017-5-8
 */
@Controller
@RequestMapping("/payment")
public class PayController{
	
	//日志记录
	private Logger logger = Logger.getLogger(PayController.class);
	
	@Resource
	private PayService payService;
	
	@RequestMapping("/alipayNotify")
	public void alipayNotify(HttpServletRequest request, HttpServletResponse response) throws Exception {
		//准备返回输出
		PrintWriter writer = response.getWriter();
		//标记回调开始
		logger.error("============================支付宝支付开始回调=================================================");
		//调用业务处理
		int result = payService.alipayNotifyProcessService(request);
		
		logger.error("====================本次业务处理结果="+result+"================================================");
		//返回业务处理结果
		writer.print(result==200?"success":"failure");
	}
	
}
